package com.italian.numbers;

import com.italian.numbers.R;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class Results extends Activity implements OnClickListener {
    
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        SharedPreferences settings = getSharedPreferences("Com.numbers.learn", 0);
        boolean exit = settings.getBoolean("exit", false);
        if(exit == true)
        	Results.this.finish();
        
    	setContentView(R.layout.records);
    	Button backToMain = (Button) findViewById(R.id.records_backInMenu);
    	backToMain.setOnClickListener(this);
    	
        TextView record01 = (TextView) findViewById(R.id.record01);
        TextView record02 = (TextView) findViewById(R.id.record02);
        TextView record03 = (TextView) findViewById(R.id.record03);
        TextView record04 = (TextView) findViewById(R.id.record04);
        TextView record05 = (TextView) findViewById(R.id.record05);
        
        record01.setText("1. "+ Integer.toString( settings.getInt("record01",0 ))+" "+getResources().getString(R.string.points));
        record02.setText("2. "+ Integer.toString( settings.getInt("record02",0 ))+" "+getResources().getString(R.string.points));
        record03.setText("3. "+ Integer.toString( settings.getInt("record03",0 ))+" "+getResources().getString(R.string.points));
        record04.setText("4. "+ Integer.toString( settings.getInt("record04",0 ))+" "+getResources().getString(R.string.points));
        record05.setText("5. "+ Integer.toString( settings.getInt("record05",0 ))+" "+getResources().getString(R.string.points));


        TextView record11 = (TextView) findViewById(R.id.record11);
        TextView record12 = (TextView) findViewById(R.id.record12);
        TextView record13 = (TextView) findViewById(R.id.record13);
        TextView record14 = (TextView) findViewById(R.id.record14);
        TextView record15 = (TextView) findViewById(R.id.record15);
        
        record11.setText("1. "+ Integer.toString( settings.getInt("record11",0 ))+" "+getResources().getString(R.string.points));
        record12.setText("2. "+ Integer.toString( settings.getInt("record12",0 ))+" "+getResources().getString(R.string.points));
        record13.setText("3. "+ Integer.toString( settings.getInt("record13",0 ))+" "+getResources().getString(R.string.points));
        record14.setText("4. "+ Integer.toString( settings.getInt("record14",0 ))+" "+getResources().getString(R.string.points));
        record15.setText("5. "+ Integer.toString( settings.getInt("record15",0 ))+" "+getResources().getString(R.string.points));
        
        TextView record21 = (TextView) findViewById(R.id.record21);
        TextView record22 = (TextView) findViewById(R.id.record22);
        TextView record23 = (TextView) findViewById(R.id.record23);
        TextView record24 = (TextView) findViewById(R.id.record24);
        TextView record25 = (TextView) findViewById(R.id.record25);
        
        record21.setText("1. "+ Integer.toString( settings.getInt("record21",0 ))+" "+getResources().getString(R.string.points));
        record22.setText("2. "+ Integer.toString( settings.getInt("record22",0 ))+" "+getResources().getString(R.string.points));
        record23.setText("3. "+ Integer.toString( settings.getInt("record23",0 ))+" "+getResources().getString(R.string.points));
        record24.setText("4. "+ Integer.toString( settings.getInt("record24",0 ))+" "+getResources().getString(R.string.points));
        record25.setText("5. "+ Integer.toString( settings.getInt("record25",0 ))+" "+getResources().getString(R.string.points));
        
        TextView record31 = (TextView) findViewById(R.id.record31);
        TextView record32 = (TextView) findViewById(R.id.record32);
        TextView record33 = (TextView) findViewById(R.id.record33);
        TextView record34 = (TextView) findViewById(R.id.record34);
        TextView record35 = (TextView) findViewById(R.id.record35);
        
        record31.setText("1. "+ Integer.toString( settings.getInt("record31",0 ))+" "+getResources().getString(R.string.points));
        record32.setText("2. "+ Integer.toString( settings.getInt("record32",0 ))+" "+getResources().getString(R.string.points));
        record33.setText("3. "+ Integer.toString( settings.getInt("record33",0 ))+" "+getResources().getString(R.string.points));
        record34.setText("4. "+ Integer.toString( settings.getInt("record34",0 ))+" "+getResources().getString(R.string.points));
        record35.setText("5. "+ Integer.toString( settings.getInt("record35",0 ))+" "+getResources().getString(R.string.points));
    	
    }
	@Override
	public void onClick(View arg0) {
    	Intent myIntent = new Intent(Results.this, Start.class);
    	Results.this.startActivity(myIntent);
    	Results.this.finish();
	}

}
